﻿using Microsoft.Graphics.Canvas;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 纸片人.win2dEffectControl.DataClass
{
    public abstract class EffectTwoSourceData : EffectOneSourceData
    {
        public EffectData InputTwoEffectData;

        /// <summary>
        /// 设置第二个输入源
        /// </summary>
        /// <param name="data"></param>
        public void SetInputTwoEffectData(EffectData data)
        {
            InputTwoEffectData = data;
            data.AddOutputSequene(this);
            this.SetIsChanges();
        }

        /// <summary>
        /// 移除第二个输入源
        /// </summary>
        public void RemoveInputTwoEffect(EffectData data)
        {
            if (InputTwoEffectData == data)
            {
                InputTwoEffectData = null;
                this.SetIsChanges();
            }
        }

        /// <summary>
        /// 获取第二个输入源的效果
        /// </summary>
        /// <param name="device"></param>
        /// <param name="compression">是否压缩</param>
        /// <returns></returns>
        protected ICanvasImage GetSourceTwoEffect(CanvasDevice device, bool compression)
        {
            if (InputTwoEffectData == null )
            {
                CanvasCommandList command = new CanvasCommandList(device);
                return command;
            }
            var source = InputTwoEffectData.GetEffect(device, compression);
            if(source == null)
            {
                return new CanvasCommandList(device);
            }

            return source;
        }


        public abstract override ICanvasImage GetEffect(CanvasDevice device, bool compression);
     

    }
}
